package com.example.applicationlifecycle;

import android.app.Application;
import android.content.Context;
import android.util.Log;

import com.lws.applicationlifecycle.AppLifeCycle;
import com.lws.applicationlifecycle.AppLifeCycleObserver;

public class SubApp2 extends Application {
    private static final String TAG = SubApp2.class.getName();



    //方法修改为public，添加观察者
    @Override
    public void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        Object appLifeCycle = base.getSystemService(AppLifeCycle.NAME);
        if (appLifeCycle instanceof AppLifeCycle) {
            ((AppLifeCycle) appLifeCycle).addAppLifeCycleObserver(this);
        }
    }

    @Override
    public void onCreate() {
        super.onCreate();
        Log.d(TAG, "onCreate: ");
    }

    @Override
    public void onTerminate() {
        super.onTerminate();
        Log.d(TAG, "onTerminate: ");
    }
}
